/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 * Origin source from MaNGOS(GPL2).
 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
 */

#ifndef __MAP_MANAGER_H__
#define __MAP_MANAGER_H__

#include "Timer.h"
#include "GridDefine.h"
#include "Map.h"
#include "Transport.h"

namespace PQServiceCore
{
	class MapManager
	{
	public:
		typedef UNORDERED_MAP<uint32, Map*> UnorderedMap;
		typedef std::pair<UNORDERED_MAP<uint32, Map*>::iterator, bool>  UnorderedMapPair;
		typedef std::set<Transport*> TransportSet;
	public:
		MapManager();
		~MapManager();
		static MapManager& getSingleton()
		{
			static MapManager inst;
			return inst;
		}

		static bool ExistMapAndVMap(uint32 mapid, float x, float y);
		void setGridCleanUpDelay(uint32 time);
		void setMapUpdateInterval(uint32 time);
		bool Initialize();
		bool LoadTransports();
		bool UnloadAll();

		void Update(unsigned int deltaT);

		void RemoveAllObjectsInRemoveList();
	private:
		uint32 _gridCleanUpDelay;
		IntervalTimer _timer;
		UnorderedMap _maps;
		TransportSet _transports;
	};

}

#define SMapMgr PQServiceCore::MapManager::getSingleton()

#endif
